/**
 * 
 */
package net.sf.cldsql.dyna.utl;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sf.cldsql.dj.mvc.DiContextServletImpl;

/**
 * ServletHlp
 */
public class ServletHlpr {

    final Logger log = LoggerFactory.getLogger(ServletHlpr.class);

    private HttpServlet servlet;

    private DynaContext context;

    /** @param servlet */
    public ServletHlpr(HttpServlet servlet) {
        this.servlet = servlet;
    }

    /** @param context */
    public ServletHlpr(DynaContext context) {
        this.context = context;
        this.servlet = context.getServerLet();
    }

    public ServletHlpr(HttpServletRequest request) {
        this((DynaContext)request.getAttribute(DynaConf.DYNA_CONTEXT_KEY));
    }


    /** @return context */
    public DiContextServletImpl getContext() {
        return context;
    }

    /** set context to request attribute to use later in jsp */
    public void initRequestAttribute() {
        context.getRequest().setAttribute(DynaConf.DYNA_CONTEXT_KEY, context);
        
    }

}
